package com.youchuang.action.main;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.youchuang.action.BaseAction;
import com.youchuang.bean.Bulltion;
import com.youchuang.common.Constant;
import com.youchuang.service.MainService;

import net.sf.json.JSONArray;

/**
 * 获得所有快报信息
 * 
 * @author Administrator
 *
 */
@Namespace(value = "/main")
@ParentPackage("shopping-default")
public class BulltionAction extends BaseAction {
	private Logger logger = Logger.getLogger(BulltionAction.class.getSimpleName());
	private List<Bulltion> bulltions;
	
	@Resource
	private MainService mainService;

	@Action(value = "bulltion", results = {
			@Result(name = Constant.SUCCESS, location = "/WEB-INF/jsp/main/bulletinBoard.jsp") })
	public String execute() throws Exception {
		logger.info("excetion is execute");

		bulltions = mainService.findBulltionByAll();

		logger.info("reponse json = " + JSONArray.fromObject(bulltions).toString());
		return ActionSupport.SUCCESS;
	}

	public Logger getLogger() {
		return logger;
	}

	public void setLogger(Logger logger) {
		this.logger = logger;
	}

	public List<Bulltion> getBulltions() {
		return bulltions;
	}

	public void setBulltions(List<Bulltion> bulltions) {
		this.bulltions = bulltions;
	}
}
